﻿using System;
using System.Collections;
using System.Text;
using FX.CC.Andon.Entity;
using FX.CC.Andon.Entity.SystemManage;
using FX.CC.Andon.Service.SystemManage;
using FX.CC.Andon.Utility.Json;

namespace FX.CC.Andon.Business.BLL.SystemManage
{
    public class NoticeBLL
    {
        private readonly NoticeDAL _dal = new NoticeDAL();

        public string GetNoticeList(Pagination qcmodel)
        {
            var total = _dal.GetTotal();
            var list = _dal.GetNoticeList(qcmodel);
            return JsonHelper.Encode(total, list);
        }

        public bool AddNotice(NoticeEntity model)
        {
            return _dal.Insert(model);
        }

        public bool ModifyNotice(NoticeEntity model)
        {
            return _dal.Modify(model);
        }
        public string GetNoticeInfo(string id)
        {
            return JsonHelper.Encode(_dal.GetNoticeInfo(id));
        }

        public bool RemoveNotice(string id)
        {
            return _dal.RemoveNotice(id);
        }

        public string ViewTxtList()
        {
            var strTxt = new StringBuilder();
            var list = _dal.ViewTxtList();
            //如果记录存在
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    strTxt.Append("<li>");
                    strTxt.Append("<em  class=\"hot\">" + (i + 1) + "</em>");
                    strTxt.Append("<span>" + list[i].NoticeTitle + "</span>");
                    strTxt.Append("</li>\n");
                }
            }
            else
            {
                strTxt.Append("<div>暂无公告数据显示...</div>");
            }
            return strTxt.ToString();

        }
    }
}
